/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * SimNao.java
 *
 * Created on 28/01/2012, 11:09:42
 */
package Formularios;

import Atributos.Curso;
import BD.CriaConexao;
import Metodos.CursoMet;
import Metodos.RelatorioMet;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import javax.swing.JOptionPane;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperExportManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;



/**
 *
 * @author André
 */
public class Grades extends javax.swing.JFrame {
static int i;
static File arquivo;
  CursoMet cursomet=new CursoMet();
  Curso curso= new Curso();
  String nome_curso;
    public Grades() {
        
        initComponents();
        BufferedImage image=null;
        File imageFile=new File(".\\src\\Imagens\\logo3.png");
        try {
            image=ImageIO.read(imageFile);
            
        } catch (IOException ex) {
        }
        this.setIconImage(image);
        jDialog1.setIconImage(image);
        
//        System.out.println(getClass().getResource("iconebarra.png").getPath());
         i=0;
       
        AlocarCurso();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jDialog1 = new javax.swing.JDialog();
        jFileChooser1 = new javax.swing.JFileChooser();
        jDesktopPane1 = new javax.swing.JDesktopPane();
        jPanel1 = new javax.swing.JPanel();
        jSeparator1 = new javax.swing.JSeparator();
        buton_adicionar1 = new javax.swing.JLabel();
        jCheckBox1 = new javax.swing.JCheckBox();
        jCheckBox2 = new javax.swing.JCheckBox();
        jCheckBox3 = new javax.swing.JCheckBox();
        jCheckBox4 = new javax.swing.JCheckBox();
        jCheckBox5 = new javax.swing.JCheckBox();
        jCheckBox6 = new javax.swing.JCheckBox();
        jCheckBox7 = new javax.swing.JCheckBox();
        jCheckBox8 = new javax.swing.JCheckBox();
        jLabelGerar = new javax.swing.JLabel();

        jFileChooser1.setFileSelectionMode(javax.swing.JFileChooser.DIRECTORIES_ONLY);
        jFileChooser1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jFileChooser1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jDialog1Layout = new javax.swing.GroupLayout(jDialog1.getContentPane());
        jDialog1.getContentPane().setLayout(jDialog1Layout);
        jDialog1Layout.setHorizontalGroup(
            jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jDialog1Layout.createSequentialGroup()
                .addComponent(jFileChooser1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );
        jDialog1Layout.setVerticalGroup(
            jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jDialog1Layout.createSequentialGroup()
                .addComponent(jFileChooser1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setTitle("Gerar Grades Curriculares");
        setResizable(false);

        jPanel1.setBackground(new java.awt.Color(0, 0, 0));
        jPanel1.setLayout(null);

        jSeparator1.setBackground(new java.awt.Color(255, 153, 0));
        jSeparator1.setForeground(new java.awt.Color(0, 0, 0));
        jSeparator1.setOrientation(javax.swing.SwingConstants.VERTICAL);
        jPanel1.add(jSeparator1);
        jSeparator1.setBounds(30, 10, 11, 300);

        buton_adicionar1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/voltar.jpg"))); // NOI18N
        buton_adicionar1.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        buton_adicionar1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                buton_adicionar1MouseClicked(evt);
            }
        });
        jPanel1.add(buton_adicionar1);
        buton_adicionar1.setBounds(40, 260, 180, 50);

        jCheckBox1.setBackground(new java.awt.Color(0, 0, 0));
        jCheckBox1.setFont(new java.awt.Font("Comic Sans MS", 2, 18)); // NOI18N
        jCheckBox1.setForeground(new java.awt.Color(255, 255, 255));
        jCheckBox1.setFocusPainted(false);
        jPanel1.add(jCheckBox1);
        jCheckBox1.setBounds(70, 40, 270, 21);

        jCheckBox2.setBackground(new java.awt.Color(0, 0, 0));
        jCheckBox2.setFont(new java.awt.Font("Comic Sans MS", 2, 18)); // NOI18N
        jCheckBox2.setForeground(new java.awt.Color(255, 255, 255));
        jCheckBox2.setFocusPainted(false);
        jPanel1.add(jCheckBox2);
        jCheckBox2.setBounds(70, 90, 270, 21);

        jCheckBox3.setBackground(new java.awt.Color(0, 0, 0));
        jCheckBox3.setFont(new java.awt.Font("Comic Sans MS", 2, 18)); // NOI18N
        jCheckBox3.setForeground(new java.awt.Color(255, 255, 255));
        jCheckBox3.setFocusPainted(false);
        jPanel1.add(jCheckBox3);
        jCheckBox3.setBounds(70, 140, 270, 21);

        jCheckBox4.setBackground(new java.awt.Color(0, 0, 0));
        jCheckBox4.setFont(new java.awt.Font("Comic Sans MS", 2, 18)); // NOI18N
        jCheckBox4.setForeground(new java.awt.Color(255, 255, 255));
        jCheckBox4.setFocusPainted(false);
        jPanel1.add(jCheckBox4);
        jCheckBox4.setBounds(70, 190, 270, 21);

        jCheckBox5.setBackground(new java.awt.Color(0, 0, 0));
        jCheckBox5.setFont(new java.awt.Font("Comic Sans MS", 2, 18)); // NOI18N
        jCheckBox5.setForeground(new java.awt.Color(255, 255, 255));
        jCheckBox5.setFocusPainted(false);
        jPanel1.add(jCheckBox5);
        jCheckBox5.setBounds(360, 40, 280, 21);

        jCheckBox6.setBackground(new java.awt.Color(0, 0, 0));
        jCheckBox6.setFont(new java.awt.Font("Comic Sans MS", 2, 18)); // NOI18N
        jCheckBox6.setForeground(new java.awt.Color(255, 255, 255));
        jCheckBox6.setFocusPainted(false);
        jPanel1.add(jCheckBox6);
        jCheckBox6.setBounds(360, 90, 280, 21);

        jCheckBox7.setBackground(new java.awt.Color(0, 0, 0));
        jCheckBox7.setFont(new java.awt.Font("Comic Sans MS", 2, 18)); // NOI18N
        jCheckBox7.setForeground(new java.awt.Color(255, 255, 255));
        jCheckBox7.setFocusPainted(false);
        jPanel1.add(jCheckBox7);
        jCheckBox7.setBounds(360, 140, 280, 21);

        jCheckBox8.setBackground(new java.awt.Color(0, 0, 0));
        jCheckBox8.setFont(new java.awt.Font("Comic Sans MS", 2, 18)); // NOI18N
        jCheckBox8.setForeground(new java.awt.Color(255, 255, 255));
        jCheckBox8.setFocusPainted(false);
        jPanel1.add(jCheckBox8);
        jCheckBox8.setBounds(360, 190, 280, 21);

        jLabelGerar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/gerar21.jpg"))); // NOI18N
        jLabelGerar.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jLabelGerar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jLabelGerarMouseClicked(evt);
            }
        });
        jPanel1.add(jLabelGerar);
        jLabelGerar.setBounds(440, 260, 200, 40);

        jPanel1.setBounds(0, 0, 690, 360);
        jDesktopPane1.add(jPanel1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jDesktopPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 673, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jDesktopPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 319, Short.MAX_VALUE)
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-689)/2, (screenSize.height-357)/2, 689, 357);
    }// </editor-fold>//GEN-END:initComponents

    private void buton_adicionar1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_buton_adicionar1MouseClicked
if(i==0){         
 dispose();
  java.awt.EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                new EscolherRelatorio().setVisible(true);
            }
        });    
   i=1;
      }
    }//GEN-LAST:event_buton_adicionar1MouseClicked

    private void jLabelGerarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelGerarMouseClicked
        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        jDialog1.setBounds((screenSize.width-625)/2, (screenSize.height-430)/2, 625, 430);
        jDialog1.setVisible(true);
//           try {
//        Connection con = (Connection) CriaConexao.getConexao();
//        HashMap parametros = new HashMap();
//        CriaConexao Con = new CriaConexao();
//        RelatorioMet obm = new RelatorioMet();
//        
//        
//        if(jCheckBox1.isSelected()){
//           
//                nome_curso = jCheckBox1.getText();
//                parametros = (HashMap) obm.Met(nome_curso);
//        ////        String adober="C:/Program Files/Adobe/Reader 10.0/Reader/AcroRd32.exe ";
//        ////        Runtime.getRuntime().exec(adober + JasperRunManager.runReportToPdfFile("./src/Relatorios/Grade2.jasper", parametros, con));
//                
//                
//                JasperPrint jp = JasperFillManager.fillReport("./src/Relatorios/Grade2.jasper", parametros,con); 
//                JasperExportManager.exportReportToPdfFile(jp, "C:/ok/"+nome_curso+".pdf");
//                
////                JasperViewer jrv = new JasperViewer (jp,false);
////                jrv.setVisible(true);
//           
//       
//        
//        }
//        if(jCheckBox2.isSelected()){
//        nome_curso = jCheckBox2.getText();
//        parametros = (HashMap) obm.Met(nome_curso);
////        String adober="C:/Program Files/Adobe/Reader 10.0/Reader/AcroRd32.exe ";
////        Runtime.getRuntime().exec(adober + JasperRunManager.runReportToPdfFile("./src/Relatorios/Grade2.jasper", parametros, con));
//        JasperPrint jp = JasperFillManager.fillReport("./src/Relatorios/Grade2.jasper", parametros,con);
//        JasperViewer jrv = new JasperViewer (jp,false);
//        jrv.setVisible(true);
//        }
//        if(jCheckBox3.isSelected()){
//        nome_curso = jCheckBox3.getText();
//        parametros = (HashMap) obm.Met(nome_curso);
////        String adober="C:/Program Files/Adobe/Reader 10.0/Reader/AcroRd32.exe ";
////        Runtime.getRuntime().exec(adober + JasperRunManager.runReportToPdfFile("./src/Relatorios/Grade2.jasper", parametros, con));     
//        JasperPrint jp = JasperFillManager.fillReport("./src/Relatorios/Grade2.jasper", parametros,con);
//        JasperViewer jrv = new JasperViewer (jp,false);
//        jrv.setVisible(true);
//        }
//        if(jCheckBox4.isSelected()){
//        nome_curso = jCheckBox4.getText();
//        parametros = (HashMap) obm.Met(nome_curso);
////        String adober="C:/Program Files/Adobe/Reader 10.0/Reader/AcroRd32.exe ";
////        Runtime.getRuntime().exec(adober + JasperRunManager.runReportToPdfFile("./src/Relatorios/Grade2.jasper", parametros, con));
//        JasperPrint jp = JasperFillManager.fillReport("./src/Relatorios/Grade2.jasper", parametros,con);
//        JasperViewer jrv = new JasperViewer (jp,false);
//        jrv.setVisible(true);
//        }
//        if(jCheckBox5.isSelected()){
//        nome_curso = jCheckBox5.getText();
//        parametros = (HashMap) obm.Met(nome_curso);
////        String adober="C:/Program Files/Adobe/Reader 10.0/Reader/AcroRd32.exe ";
////        Runtime.getRuntime().exec(adober + JasperRunManager.runReportToPdfFile("./src/Relatorios/Grade2.jasper", parametros, con));
//        JasperPrint jp = JasperFillManager.fillReport("./src/Relatorios/Grade2.jasper", parametros,con);
//        JasperViewer jrv = new JasperViewer (jp,false);
//        jrv.setVisible(true);
//        }
//        if(jCheckBox6.isSelected()){
//        nome_curso = jCheckBox6.getText();
//        parametros = (HashMap) obm.Met(nome_curso);
//        JasperPrint jp = JasperFillManager.fillReport("./src/Relatorios/Grade2.jasper", parametros,con);
//        JasperViewer jrv = new JasperViewer (jp,false);
//        jrv.setVisible(true);
//        }
//        if(jCheckBox7.isSelected()){
//        nome_curso = jCheckBox7.getText();
//        parametros = (HashMap) obm.Met(nome_curso);
//        JasperPrint jp = JasperFillManager.fillReport("./src/Relatorios/Grade2.jasper", parametros,con);
//        JasperViewer jrv = new JasperViewer (jp,false);
//        jrv.setVisible(true);
//        }
//        if(jCheckBox8.isSelected()){
//        nome_curso = jCheckBox8.getText();
//        parametros = (HashMap) obm.Met(nome_curso);
//        JasperPrint jp = JasperFillManager.fillReport("./src/Relatorios/Grade2.jasper", parametros,con);
//        JasperViewer jrv = new JasperViewer (jp,false);
//        jrv.setVisible(true);
//        }       
//     }  catch (SQLException ex) {
//            Logger.getLogger(Grades.class.getName()).log(Level.SEVERE, null, ex);
//        } catch (JRException ex) {
//                Logger.getLogger(Grades.class.getName()).log(Level.SEVERE, null, ex);
//            }
       
    }//GEN-LAST:event_jLabelGerarMouseClicked

    private void jFileChooser1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jFileChooser1ActionPerformed
       
            arquivo = jFileChooser1.getSelectedFile();
            
                
            jDialog1.setVisible(false);
            if(arquivo!=null){
            String adober;
            
            adober=String.valueOf(arquivo);
            File pasta = new File(adober+"/Relatorios");
            pasta.mkdir();
            adober=adober+"/Relatorios";
            System.out.println(adober);
            if(!adober.equals("null")){
             try {
            Connection con = (Connection) CriaConexao.getConexao();
            
            HashMap parametros = new HashMap();
            
            CriaConexao Con = new CriaConexao();
            RelatorioMet obm = new RelatorioMet();
            
            File f=new File(adober+"/Grades Curriculares");
            f.delete();
            File dir2 = new File(adober+"/Grades Curriculares");
               dir2.mkdir();
                   String adober2;
                    adober2 = String.valueOf(dir2);
            if(jCheckBox1.isSelected()){   
                
                    nome_curso = jCheckBox1.getText();
                    parametros = (HashMap) obm.Met(nome_curso);
                    parametros.put("logo", getClass().getResourceAsStream("iconebarra.png"));
                    JasperPrint jp = null; 
                try {
                    jp = JasperFillManager.fillReport("./src/Relatorios/Grade2.jasper", parametros,con);
                } catch (JRException ex) {
                    Logger.getLogger(Grades.class.getName()).log(Level.SEVERE, null, ex);
                }
                try {
                    JasperExportManager.exportReportToPdfFile(jp, adober2+"/"+nome_curso+".pdf");
                } catch (JRException ex) {
                    Logger.getLogger(Grades.class.getName()).log(Level.SEVERE, null, ex);
                }
                System.out.println("salvou "+nome_curso);
            }if(jCheckBox2.isSelected()){   
                
                    nome_curso = jCheckBox2.getText();
                    parametros = (HashMap) obm.Met(nome_curso);
                    parametros.put("logo", getClass().getResourceAsStream("iconebarra.png"));
                    JasperPrint jp = null; 
                try {
                    jp = JasperFillManager.fillReport("./src/Relatorios/Grade2.jasper", parametros,con);
                } catch (JRException ex) {
                    Logger.getLogger(Grades.class.getName()).log(Level.SEVERE, null, ex);
                }
                try {
                    JasperExportManager.exportReportToPdfFile(jp, adober2+"/"+nome_curso+".pdf");
                } catch (JRException ex) {
                    Logger.getLogger(Grades.class.getName()).log(Level.SEVERE, null, ex);
                }
                System.out.println("salvou "+nome_curso);
            }
            if(jCheckBox3.isSelected()){   
                
                    nome_curso = jCheckBox3.getText();
                    parametros = (HashMap) obm.Met(nome_curso);
                    parametros.put("logo", getClass().getResourceAsStream("iconebarra.png"));
                    JasperPrint jp = null; 
                try {
                    jp = JasperFillManager.fillReport("./src/Relatorios/Grade2.jasper", parametros,con);
                } catch (JRException ex) {
                    Logger.getLogger(Grades.class.getName()).log(Level.SEVERE, null, ex);
                }
                try {
                    JasperExportManager.exportReportToPdfFile(jp, adober2+"/"+nome_curso+".pdf");
                } catch (JRException ex) {
                    Logger.getLogger(Grades.class.getName()).log(Level.SEVERE, null, ex);
                }
                System.out.println("salvou "+nome_curso);
            }
            if(jCheckBox4.isSelected()){   
                
                    nome_curso = jCheckBox4.getText();
                    parametros = (HashMap) obm.Met(nome_curso);
                    parametros.put("logo", getClass().getResourceAsStream("iconebarra.png"));
                    JasperPrint jp = null; 
                try {
                    jp = JasperFillManager.fillReport("./src/Relatorios/Grade2.jasper", parametros,con);
                } catch (JRException ex) {
                    Logger.getLogger(Grades.class.getName()).log(Level.SEVERE, null, ex);
                }
                try {
                    JasperExportManager.exportReportToPdfFile(jp, adober2+"/"+nome_curso+".pdf");
                } catch (JRException ex) {
                    Logger.getLogger(Grades.class.getName()).log(Level.SEVERE, null, ex);
                }
                System.out.println("salvou "+nome_curso);
            }
            if(jCheckBox5.isSelected()){   
                
                    nome_curso = jCheckBox5.getText();
                    parametros = (HashMap) obm.Met(nome_curso);
                    parametros.put("logo", getClass().getResourceAsStream("iconebarra.png"));
                    JasperPrint jp = null; 
                try {
                    jp = JasperFillManager.fillReport("./src/Relatorios/Grade2.jasper", parametros,con);
                } catch (JRException ex) {
                    Logger.getLogger(Grades.class.getName()).log(Level.SEVERE, null, ex);
                }
                try {
                    JasperExportManager.exportReportToPdfFile(jp, adober2+"/"+nome_curso+".pdf");
                } catch (JRException ex) {
                    Logger.getLogger(Grades.class.getName()).log(Level.SEVERE, null, ex);
                }
                System.out.println("salvou "+nome_curso);
            }
            if(jCheckBox6.isSelected()){   
                
                    nome_curso = jCheckBox6.getText();
                    parametros = (HashMap) obm.Met(nome_curso);
                    parametros.put("logo", getClass().getResourceAsStream("iconebarra.png"));
                    JasperPrint jp = null; 
                try {
                    jp = JasperFillManager.fillReport("./src/Relatorios/Grade2.jasper", parametros,con);
                } catch (JRException ex) {
                    Logger.getLogger(Grades.class.getName()).log(Level.SEVERE, null, ex);
                }
                try {
                    JasperExportManager.exportReportToPdfFile(jp, adober2+"/"+nome_curso+".pdf");
                } catch (JRException ex) {
                    Logger.getLogger(Grades.class.getName()).log(Level.SEVERE, null, ex);
                }
                System.out.println("salvou "+nome_curso);
            }
            if(jCheckBox7.isSelected()){   
                
                    nome_curso = jCheckBox7.getText();
                    parametros = (HashMap) obm.Met(nome_curso);
                    parametros.put("logo", getClass().getResourceAsStream("iconebarra.png"));
                    JasperPrint jp = null; 
                try {
                    jp = JasperFillManager.fillReport("./src/Relatorios/Grade2.jasper", parametros,con);
                } catch (JRException ex) {
                    Logger.getLogger(Grades.class.getName()).log(Level.SEVERE, null, ex);
                }
                try {
                    JasperExportManager.exportReportToPdfFile(jp, adober2+"/"+nome_curso+".pdf");
                } catch (JRException ex) {
                    Logger.getLogger(Grades.class.getName()).log(Level.SEVERE, null, ex);
                }
                System.out.println("salvou "+nome_curso);
            }
            if(jCheckBox8.isSelected()){   
                
                    nome_curso = jCheckBox8.getText();
                    parametros = (HashMap) obm.Met(nome_curso);
                    parametros.put("logo", getClass().getResourceAsStream("iconebarra.png"));
                    JasperPrint jp = null; 
                try {
                    jp = JasperFillManager.fillReport("./src/Relatorios/Grade2.jasper", parametros,con);
                } catch (JRException ex) {
                    Logger.getLogger(Grades.class.getName()).log(Level.SEVERE, null, ex);
                }
                try {
                    JasperExportManager.exportReportToPdfFile(jp, adober2+"/"+nome_curso+".pdf");
                } catch (JRException ex) {
                    Logger.getLogger(Grades.class.getName()).log(Level.SEVERE, null, ex);
                }
                System.out.println("salvou "+nome_curso);
            
               }    
        } catch (SQLException ex) {
            Logger.getLogger(Grades.class.getName()).log(Level.SEVERE, null, ex);
        }
        
            }
            JOptionPane.showMessageDialog(rootPane, "Grade(s) curriculare(s) gerada(s) com sucesso");
            }
    }//GEN-LAST:event_jFileChooser1ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Grades.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Grades.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Grades.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Grades.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                new Grades().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel buton_adicionar1;
    private javax.swing.JCheckBox jCheckBox1;
    private javax.swing.JCheckBox jCheckBox2;
    private javax.swing.JCheckBox jCheckBox3;
    private javax.swing.JCheckBox jCheckBox4;
    private javax.swing.JCheckBox jCheckBox5;
    private javax.swing.JCheckBox jCheckBox6;
    private javax.swing.JCheckBox jCheckBox7;
    private javax.swing.JCheckBox jCheckBox8;
    private javax.swing.JDesktopPane jDesktopPane1;
    private javax.swing.JDialog jDialog1;
    private javax.swing.JFileChooser jFileChooser1;
    private javax.swing.JLabel jLabelGerar;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JSeparator jSeparator1;
    // End of variables declaration//GEN-END:variables
String a="",b="",c="",d="",e="",f="",g="",h="";
String v[]={a,b,c,d,e,f,g,h};
    private void AlocarCurso() {
         String[] cursos = cursomet.Buscar_Nome_Cursos();
         for(int i=0;i<cursos.length;i++){
           v[i]=cursos[i];  
         }
         jCheckBox1.setText(v[0]);
         jCheckBox2.setText(v[1]);
         jCheckBox3.setText(v[2]);
         jCheckBox4.setText(v[3]);
         jCheckBox5.setText(v[4]);
         jCheckBox6.setText(v[5]);
         jCheckBox7.setText(v[6]);
         jCheckBox8.setText(v[7]);
         if("".equals(jCheckBox1.getText())){
             jCheckBox1.setVisible(false);
         }
         if("".equals(jCheckBox2.getText())){
             jCheckBox2.setVisible(false);
         }
         if("".equals(jCheckBox3.getText())){
             jCheckBox3.setVisible(false);
         }
         if("".equals(jCheckBox4.getText())){
             jCheckBox4.setVisible(false);
         }
         if("".equals(jCheckBox5.getText())){
             jCheckBox5.setVisible(false);
         }
         if("".equals(jCheckBox6.getText())){
             jCheckBox6.setVisible(false);
         }
         if("".equals(jCheckBox7.getText())){
             jCheckBox7.setVisible(false);
         }
         if("".equals(jCheckBox8.getText())){
             jCheckBox8.setVisible(false);
         }
        
         
    }
}
